home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pascalt2.zip
/
TIMEDATE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-01-15
|
1KB
|
42 lines
program Get_Time_And_Date;
var Year,Month,Day : integer;
Hour,Minute,Second : integer;
(* The following procedure can be included in any MSDOS/PCDOS
program to get the present date and time. The present date
and time can then be printed on your output to automatically
time and date your output listings. Note that this is a TURBO
Pascal extension and will probably not work with other Pascal
compilers. This program uses some very advanced programming
techniques requiring knowledge of some of the details of the
DOS system. Don't worry if you don't understand all of this.
*)
procedure Time_And_Date(var Year,Month,Day,Hour,Min,Sec : integer);
type Reg_Definitions = record
AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : integer;
end;
var Registers : Reg_Definitions;
begin
Registers.AX := $2A shl 8; (* get todays date *)
Msdos(Registers);
Year := Registers.CX;
Day := Registers.DX mod 256;
Month := Registers.DX shr 8;
Registers.AX := $2C shl 8; (* get the time *)
Msdos(Registers);
Hour := Registers.CX shr 8;
Min := Registers.CX mod 256;
Sec := Registers.DX shr 8;
end;
begin
Time_And_Date(Year,Month,Day,Hour,Minute,Second);
Writeln('The date is ',Month:2,'/',Day:2,'/',Year);
Writeln('The time is ',Hour:2,':',Minute:2,':',Second:2);
end.